<%- column_div :type => :primary do -%>
  <h2>Edit profile</h2>

  <div id="profile_edit">

  <h3>Personal details</h3>

    <%= error_messages_for :person %>
    
    <% form_for @person do |f| %>

      <div class="form_row">
        <label for="person_name">Name</label>
        <%= f.text_field :name, :maxlength => Person::MAX_NAME %>
      </div>
  
      <div class="form_row">
        <label for="person_description">Description
        </label>
    
        <%- unless @preview.nil? -%>
          <%= display @preview %>
        <%- end -%>
        
        <p><%= formatting_note %></p>
        <%= f.text_area :description %>
      </div>

      <div class="form_row">
        <label for="person_email">Email</label>
        <%= f.text_field :email, :maxlength => Person::MAX_EMAIL %>
      </div>
      
      <%- if global_prefs.email_notifications? -%>
      
        <br />
      
        <h3>Email notification preferences</h3>
      
        <p>
          You will receive email notifications
          for each event type whose box is checked.
        </p>
        
      
        <div class="form_row">
          <p>
          <label for="connection_notifications"
                 class="checkbox">Connections:</label>
          <%= f.check_box :connection_notifications %>
          </p>
          <p>
          <label for="message_notifications"
                 class="checkbox">Messages:</label>
          <%= f.check_box :message_notifications %>
          </p>
          <p>
          <label for="wall_comment_notifications"
                 class="checkbox">Wall comments:</label>
          <%= f.check_box :wall_comment_notifications %>
          </p>
          <p>
          <label for="blog_comment_notifications"
                 class="checkbox">Blog comments:</label>
          <%= f.check_box :blog_comment_notifications %>
          </p>
        </div>
      <%- end -%>
      
      <br />
  
      <div class="form_row">
        <%= f.submit "Update", :class => "button" %>
        <%= f.submit "Preview", :id => "preview", :class => "button" %>
      </div>
      <input type="hidden" name="type" value="info_edit" />
  <% end %>

  <br />

  <h3>Photos</h3>
  
    <% if @person.photos.empty? %>
      <%= image_tag @person.thumbnail %>
    <% else %>
    <table>
      <% @person.sorted_photos.collect_every(N_COLUMNS) do |row| %>
      <tr>
      <% row.each do |photo| %>
        <td  style="padding-left: 1em;">
          <%= image_tag photo.public_filename(:thumbnail) %>
        </td>
      <% end %>
      </tr>
      <tr>
        <% row.each do |photo| %>
        <td style="padding-left: 1em;">
          <% if photo.primary? %>
            primary
          <% else %>
            <%= link_to "select", photo_path(photo),
                                          :method => :put %>
          <% end %>
          |
          <%= link_to image_tag("icons/close.gif"), photo_path(photo),
                                               :method => :delete %>
        </td>
        <% end %>
      </tr>
      <% end %>
    </table>
    <% end %>
    <br />
    <%= button_to "Add a photo", new_photo_path, :class => "button" %>
  </div>

  <br />

  <% form_for @person, :html => { :id => "change_password" } do |f| %>

    <h3>Change Password</h3>

    <div class="form_row">
      <label for="password">Current Password</label>
      <%= f.password_field :verify_password,
                           :maxlength => Person::MAX_PASSWORD %>
    </div>

    <div class="form_row">
      <label for="password">New Password</label>
      <%= f.password_field :new_password,
                           :maxlength => Person::MAX_PASSWORD %>
    </div>

    <div class="form_row">
      <label for="password_confirmation">Confirm Password</label>
      <%= f.password_field :password_confirmation, 
                           :maxlength => Person::MAX_PASSWORD,
                           :value => "" %>
    </div>
    <div class="form_row">
      <%= submit_tag 'Change password', :class => "button" %>
    </div>
    <input type="hidden" name="type" value="password_edit" />
  <% end %>
<%- end -%>

<%- column_div :type => :secondary do -%>
  <%= render :partial => 'searches/box' %>
<%- end -%>